import request from '@/utils/request'
// 自定义url数据对象
export const getUrlDataApi = (url: string, params: object) => {
    return request({
        url: url,
        method: 'get',
        params
    })
};
// 自定义url数据对象
export const postUrlDataApi = (url: string, data: object) => {
    return request({
        url: url,
        method: 'post',
        data
    })
};
// 获取数据对象管理table
export const getDataApi = (data: object) => {
    return request({
        url: '/meta/tInfoSjjSjdx/list',
        method: 'post',
        data
    })
};

//导出数据对象excel
export const exportExcel = () => {
    return request({
        url: '/meta/tInfoSjjSjdx/export',
        method: 'post',
    })
};

//删除
export const remove = (ids: string) => {
    const data = { ids }
    return request({
        url: '/meta/tInfoSjjSjdx/remove',
        method: 'post',
        data
    })
};

//用户
export const schemaList = (id: string) => {
    const params = { id }
    return request({
        url: '/meta/tInfoSjy/schemaList',
        method: 'get',
        params
    })
};

//数据库查看字段
export const tableOrViewList = (id: string, ssyh: string, sjdxlx: string) => {
    const params = { id, ssyh, sjdxlx }
    return request({
        url: '/meta/tInfoSjy/tableOrViewList',
        method: 'get',
        params
    })
};

//数据库 编辑
export const edit = (data: object) => {
    return request({
        url: '/meta/tInfoSjjSjdx/edit',
        method: 'post',
        data
    })
};

//数据库表名
export const addData = (data: object) => {
    return request({
        url: '/meta/tInfoSjjSjdx/add',
        method: 'post',
        data
    })
};

//数据项-编辑
export const dataEdit = (data: object) => {
    return request({
        url: '/meta/tInfoSjjZd/edit',
        method: 'post',
        data
    })
};

//分配数据字段list
export const setField = (id: string) => {
    const params = { id }
    return request({
        url: '/meta/tInfoSjjSjdx/allocateColumns',
        method: 'get',
        params
    })
};

//分配数据字段 删除
export const setFieldRemove = (ids: string) => {
    return request({
        url: '/meta/tInfoSjjZd/remove',
        method: 'post',
        data: { ids }
    })
};

// 预览
export const dataPreview = (id: string) => {
    return request({
        url: '/meta/tInfoSjjSjdx/showDataBysjdxid',
        method: 'get',
        params: { id }
    })
};

//地址匹配列表
export const addressMatchApi = (sjdxid: string) => {
    return request({
        url: '/meta/tInfoSjjSjdx/matchData',
        method: 'post',
        data: { sjdxid }
    })
};

//抽取
export const getTableApi = (sjdxid: string) => {
    return request({
        url: '/meta/tInfoSjjSjdx/accessData',
        method: 'post',
        data: { sjdxid }
    })
};

//数据对象-编辑
export const dataObjectApi = (data: object) => {
    return request({
        url: '/meta/tInfoSjjSjdx/edit',
        method: 'post',
        data
    })
};

// 预览 shis
export const dataPreview_v = (tableName: string) => {
    return request({
        url: '/meta/tInfoSjjSjdx/showDataByTableName',
        method: 'get',
        params: { tableName }
    })
};


//预览保存数据
export const saveColumnApi = (data: object) => {
    return request({
        url: '/meta/tInfoSjjZd/saveColumn',
        method: 'post',
        data
    })
};
